package zut.edu.cs.network.io.readerwriter;

import java.io.FileWriter;
import java.io.IOException;

public class FileWriterDemo {

	public static void main(String[] args) {
		try {
			FileWriter file = new FileWriter("test.txt");
			file.write("这次是直接写入\n");
//			控制写入字符串的起始位置和长度
			String str = "i am sweet";
			file.write(str, 2, 8);
			file.close();
			System.out.println("写入成功!");
			
		} catch (IOException e) {
			System.out.println("写入错误！");
			e.printStackTrace();
		}

	}

}
